<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>vue组件2</title>
    <script src="../../js/vue3.js"></script>
    <style>
        #app {
            margin: 2rem auto;
            width: 30%;
        }
        
        p {
            font-size: 1.5rem;
            font-weight: bold;
        }
    </style>
</head>

<body>
    <div id="app">
        <text-part></text-part>
        <text-part></text-part>
        <button-click></button-click>
    </div>
    <div id="app2">
        <text-part></text-part>
        <text-part></text-part>
        <button-click></button-click>
    </div>
    <script>
        const v_app = Vue.createApp({
            data() {
                return {
                    msg: "文本"
                }
            },
            components: {
                ButtonClick: {
                    data() {
                        return {
                            count: 0
                        }
                    },
                    template: "<button @click='count++'>增加</button>{{count}}"
                }
            }
        });
        v_app.component("text-part", {
            data() {
                return {
                    msg: "text-part"
                }
            },
            template: "<h1>{{msg}}</h1>"
        })

        v_app.mount("#app");
        const v_app2 = Vue.createApp({
            data() {
                return {
                    msg: "文本"
                }
            }
        });
        v_app2.component("text-part", {
            data() {
                return {
                    msg: "text-part"
                }
            },
            template: "<h1>{{msg}}</h1>"
        })

        v_app2.mount("#app2");
    </script>
</body>

</html>